/*
 * CadastrodeOrdemProducao.java
 *
 * Created on 26 de Novembro de 2008, 16:22
 */
package br.faimg.pomar.visual;

import br.faimg.pomar.controle.componentevisual.TableOrdemdeProducao;
import javax.swing.JTable;



/**
 *
 * @author  Juliana
 */
public class CadastrodeOrdemdeProducao extends javax.swing.JInternalFrame {
      
    /** Creates new form CadastrodeEstacao */
    public CadastrodeOrdemdeProducao() {
        initComponents();


        updateTable();

    }

    private void updateTable() {
        //Lista os itens cadastrados no banco na tablela
         tabelaOrdemdeProducaojTable.setModel(new JTable(
         new TableOrdemdeProducao().getTableModel()
         ).getModel());


        //remove a coluna do codigo do produto
        tabelaOrdemdeProducaojTable.removeColumn(tabelaOrdemdeProducaojTable.getColumn("Codigo do Produto"));
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        cancelarButton = new javax.swing.JButton();
        okButton = new javax.swing.JButton();
        tabelaScrollPane = new javax.swing.JScrollPane();
        tabelaOrdemdeProducaojTable = new javax.swing.JTable();
        jSeparator1 = new javax.swing.JSeparator();

        setResizable(true);
        setTitle("Cadastro de Ordem de Producao");
        setVerifyInputWhenFocusTarget(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        cancelarButton.setText("Cancelar");
        cancelarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarButtonActionPerformed(evt);
            }
        });
        jPanel1.add(cancelarButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 330, 90, -1));

        okButton.setText("Incluir");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
        jPanel1.add(okButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 330, 90, -1));

        tabelaScrollPane.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelaScrollPaneMouseClicked(evt);
            }
        });

        tabelaOrdemdeProducaojTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tabelaOrdemdeProducaojTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelaOrdemdeProducaojTableMouseClicked(evt);
            }
        });
        tabelaScrollPane.setViewportView(tabelaOrdemdeProducaojTable);

        jPanel1.add(tabelaScrollPane, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 630, 300));
        jPanel1.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 130, 610, 10));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 660, 380));

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void cancelarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarButtonActionPerformed
    this.setVisible(false);
}//GEN-LAST:event_cancelarButtonActionPerformed

private void tabelaScrollPaneMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaScrollPaneMouseClicked

}//GEN-LAST:event_tabelaScrollPaneMouseClicked

private void tabelaOrdemdeProducaojTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaOrdemdeProducaojTableMouseClicked

}//GEN-LAST:event_tabelaOrdemdeProducaojTableMouseClicked

private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
    CadastrodeOrdemdeProducaoInclusao view = new CadastrodeOrdemdeProducaoInclusao();
   
    view.setModal(true);
    view.setResizable(true);
    view.setVisible(true);
    
    updateTable();
}//GEN-LAST:event_okButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelarButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton okButton;
    private javax.swing.JTable tabelaOrdemdeProducaojTable;
    private javax.swing.JScrollPane tabelaScrollPane;
    // End of variables declaration//GEN-END:variables
}
